<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .rectangle {
            width: 400px;
            height: 400px;
            background-color: red;
            clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
        }
    </style>
</head>
<body>
    
    <canvas id="myCanvas" width="500px" height="500px"></canvas>
    <script>
        const ct = document.getElementById("myCanvas");
        let ctx = ct.getContext("2d");

ctx.beginPath()
ctx.moveTo(100,100);//移动到某个点；
ctx.lineTo(200,100);//中点坐标；
ctx.lineWidth = '10';//线条 宽度 
ctx.strokeStyle = 'blue';//rgba(0,222,255,.5)

ctx.stroke();//描边 

    </script>
</body>
</html>